var rules = [
	  {
	    name : "Hi rule",
	    active : true
	  },
	  {
	    name : "Luki",
	    active : false
	  }
  ];

var template;

function newRule(rule) {
  rules.push(rule)
  fetchRules()
}

function fetchRules() {
  $('stuff').update(template.process($A(rules)));
}

function respondToClick(event){
  Event.stop(event)	
  newRule({name : 'NewRule',  active : false})
  return false
}

function bindUI() {
	
  $('newRule').observe('click', respondToClick);	
  template = TrimPath.parseDOMTemplate("rules_jst");	
  fetchRules()
}

document.observe('dom:loaded', bindUI);

